package com.jwaoo.mobile;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.Nullable;

import com.dx.as.JWCache;
import com.jwaoo.mobile.view.login.LoginActivity;
import com.jwaoo.mobile.view.main.MainActivity;

/**
 * Created by jwaoo on 2017/6/12.
 */

public class SplashActivity extends Activity{
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);
        toMainView();
    }

    private void toMainView(){
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                Intent mainIntent = new Intent();
                if (JWCache.isLogin()){
                    mainIntent.setClass(SplashActivity.this, MainActivity.class);
                }else {
                    mainIntent.setClass(SplashActivity.this, LoginActivity.class);
                }
                startActivity(mainIntent);
                finish();
            }
        },500);
    }
}
